package com.micro.modual.controller;

import com.micro.core.resp.RespJson;
import com.micro.core.resp.RespJsonData;
import com.micro.core.resp.RespJsonPageData;
import com.micro.modual.model.bo.assembleconfig.AssembleConfigBO;
import com.micro.modual.model.dto.assembleconfig.AssembleConfigDetailDTO;
import com.micro.modual.model.dto.assembleconfig.AssembleConfigListDTO;
import com.micro.modual.service.AssembleConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

import java.util.Map;

/**
 * <h1>拼团配置表 控制器</h1>
 * @author levelcoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:27:47
 */
@Api(value = "拼团配置管理",tags = "拼团配置管理")
@RestController
@RequestMapping(value = "assembleConfig")
public class AssembleConfigController {

    @Autowired
    private AssembleConfigService assembleConfigService;

    /**
     * <h2>查找拼团配置表 列表</h2>
     * @param params 列表查询请求对象
     * @return List<AssembleConfigListDTO> {@link AssembleConfigListDTO}s  拼团配置表 列表返回对象
     */
    @ApiOperation(value = "查询拼团配置表列表" ,notes = "查询拼团配置表列表")
    @GetMapping(value = "/findAssembleConfigList")
    public RespJsonPageData<AssembleConfigListDTO> findAssembleConfigList(@RequestParam  Map<String,Object> params){
        return assembleConfigService.findList(params,AssembleConfigListDTO.class);
    }

    /**
     * <h2>根据主键编号查看拼团配置表详情</h2>
     * @param id  拼团配置表 主键编号
     * @return {@link AssembleConfigDetailDTO}  拼团配置表 详情
     */
    @ApiOperation(value = "查询拼团配置表详情",notes = "根据主键编号，查询拼团配置表详情")
    @GetMapping(value = "/findAssembleConfigDetail/{id}")
    public RespJsonData<AssembleConfigDetailDTO> findAssembleConfigDetail(@PathVariable("id") Long id){
        return assembleConfigService.findDetail(id,AssembleConfigDetailDTO.class);
    }

    /**
     * <h2>新增拼团配置表详情</h2>
     * @param assembleConfigBO {@link AssembleConfigBO} 拼团配置表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "新增拼团配置表",notes = "新增拼团配置表")
    @PostMapping(value = "/addAssembleConfig")
    public RespJson addAssembleConfig(@RequestBody AssembleConfigBO assembleConfigBO){
        return assembleConfigService.addAssembleConfig(assembleConfigBO);
    }

    /**
     * <h2>修改拼团配置表详情</h2>
     * @param assembleConfigBO  {@link AssembleConfigBO} 拼团配置表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "修改拼团配置表",notes = "修改拼团配置表")
    @PostMapping(value = "/editAssembleConfig")
    public RespJson editAssembleConfig(@RequestBody AssembleConfigBO assembleConfigBO){
        return assembleConfigService.editAssembleConfig(assembleConfigBO);
    }

    /**
     * <h2>根据主键编号删除拼团配置表信息</h2>
     * @param id  拼团配置表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */
    @ApiOperation(value = "删除拼团配置表",notes = "根据地址ID，删除拼团配置表")
    @PostMapping(value = "/deleteAssembleConfig/{id}")
    public RespJson deleteAssembleConfig(@PathVariable("id") Long id){
        return assembleConfigService.deleteAssembleConfig(id);
    }
}

